package org.digitalsoul.switchplugin.editoractions;

import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;


public abstract class AbstractEditorAction {

	public abstract void applyAction(IFile newFile, IFile lastFile, IEditorPart newEditor, IEditorPart oldEditor);

	protected ISelection getSelection(IEditorPart editorPart) {
		IEditorSite site = editorPart.getEditorSite();
		ISelection selection = null;
		if (site != null) {
			ISelectionProvider provider = site.getSelectionProvider();
			if (provider != null) {
				selection = provider.getSelection();
			}
		}
		return selection;
	}
}
